
// <copyright file="DynamicCopyHelperExtensions.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The dynamic copy helper extensions.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Extensions
{
    using SubhadraSolutions.Sharp.Utils.Reflection;

    /// <summary>
    /// The dynamic copy helper extensions.
    /// </summary>
    public static class DynamicCopyHelperExtensions
    {
        #region Public Methods and Operators

        /// <summary>
        /// The dynamic copy.
        /// </summary>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <typeparam name="T">
        /// </typeparam>
        /// <returns>
        /// The <see cref="T"/>.
        /// </returns>
        public static T DynamicCopy<T>(T source) where T : new()
        {
            var target = new T();
            DynamicCopyHelper<T, T>.Copy(source, target);
            return target;
        }

        /// <summary>
        /// The dynamic copy.
        /// </summary>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <typeparam name="T">
        /// </typeparam>
        public static void DynamicCopy<T>(T source, T target)
        {
            DynamicCopyHelper<T, T>.Copy(source, target);
        }

        /// <summary>
        /// The dynamic copy.
        /// </summary>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="target">
        /// The target.
        /// </param>
        /// <typeparam name="TSource">
        /// </typeparam>
        /// <typeparam name="TTarget">
        /// </typeparam>
        public static void DynamicCopy<TSource, TTarget>(TSource source, TTarget target)
        {
            DynamicCopyHelper<TSource, TTarget>.Copy(source, target);
        }

        #endregion Public Methods and Operators
    }
}
